package com.iknow.view.widget;

import android.content.Context;
import android.content.res.Resources;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.PopupWindow;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.ViewFlipper;
import com.iknow.IKnow;
import com.iknow.app.IKnowSystemConfig;
import com.iknow.ui.model.IKPageAdapter;

public class PageMenuMore extends PopupWindow
{
  private View.OnClickListener ChildImageButtonListener;
  public Context ctx = null;
  protected View fontSet;
  protected TextView font_progressShow;
  protected TextView light_progressShow;
  protected IKPageAdapter mAdapter;
  private View.OnClickListener mBtnOnClickListener;
  protected MyListView mListView;
  protected SeekBar mSeekBar_font;
  protected SeekBar mSeekBar_light;
  protected TextView mTitleText;
  protected ViewFlipper mViewFlipper;
  protected View nightSet;
  protected View popView = null;
  private ImageButton switch_bn_auto;
  private ImageButton switch_bn_light;
  protected View wordSelectSet;

  public PageMenuMore(Context paramContext, MyListView paramMyListView, IKPageAdapter paramIKPageAdapter, TextView paramTextView, View paramView, int paramInt)
  {
    super(paramView, paramInt * 3 - 10, -2);
    this.mListView = null;
    this.mAdapter = null;
    this.mViewFlipper = null;
    this.mSeekBar_font = null;
    this.mSeekBar_light = null;
    this.switch_bn_light = null;
    this.switch_bn_auto = null;
    this.light_progressShow = null;
    this.font_progressShow = null;
    this.fontSet = null;
    this.nightSet = null;
    this.wordSelectSet = null;
    this.mTitleText = null;
    this.mBtnOnClickListener = new View.OnClickListener(this)
    {
      public void onClick()
      {
        this.this$0.getViewFlipper().setVisibility(0);
        switch (paramView.getId())
        {
        default:
        case 2131296496:
        case 2131296497:
        }
        while (true)
        {
          while (true)
          {
            return;
            this.this$0.getViewFlipper().setDisplayedChild(0);
          }
          this.this$0.getViewFlipper().setDisplayedChild(1);
        }
      }
    };
    this.ChildImageButtonListener = new View.OnClickListener(this)
    {
      private boolean isOpen = true;
      private boolean open = true;

      public void onClick()
      {
        switch (paramView.getId())
        {
        default:
        case 2131296365:
        case 2131296368:
        case 2131296507:
        }
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    return;
                    if (!(this.isOpen))
                      break;
                    this.this$0.mTitleText.setTextColor(this.this$0.ctx.getResources().getColor(2131165201));
                    IKnow.mSystemConfig.setBook_TextColorRes(this.this$0.mAdapter, 2131165201);
                    this.this$0.mListView.setBackgroundColor(this.this$0.ctx.getResources().getColor(2131165185));
                    IKnow.mSystemConfig.setBook_BackGroundRes(this.this$0.ctx, 2131165185);
                    IKnow.mSystemConfig.setBoolean("switch_bn_light", true);
                    PageMenuMore.access$0(this.this$0).setImageResource(2130837768);
                    this.isOpen = false;
                  }
                  this.this$0.mTitleText.setTextColor(this.this$0.ctx.getResources().getColor(2131165184));
                  IKnow.mSystemConfig.setBook_TextColorRes(this.this$0.mAdapter, 2131165184);
                  this.this$0.mListView.setBackgroundColor(this.this$0.ctx.getResources().getColor(2131165210));
                  IKnow.mSystemConfig.setBook_BackGroundRes(this.this$0.ctx, 2131165210);
                  IKnow.mSystemConfig.setBoolean("switch_bn_light", false);
                  PageMenuMore.access$0(this.this$0).setImageResource(2130837767);
                  this.isOpen = true;
                }
                if (!(this.isOpen))
                  break;
                IKnow.mSystemConfig.setBoolean("switch_bn_word", true);
                this.isOpen = false;
              }
              IKnow.mSystemConfig.setBoolean("switch_bn_word", false);
              this.isOpen = true;
            }
            if (!(this.open))
              break;
            IKnow.mSystemConfig.setBoolean("switch_bn_auto", true);
            PageMenuMore.access$1(this.this$0).setImageResource(2130837768);
            this.open = false;
          }
          IKnow.mSystemConfig.setBoolean("switch_bn_auto", false);
          PageMenuMore.access$1(this.this$0).setImageResource(2130837767);
          this.open = true;
        }
      }
    };
    this.ctx = paramContext;
    this.mListView = paramMyListView;
    this.mAdapter = paramIKPageAdapter;
    this.popView = paramView;
    this.mTitleText = paramTextView;
  }

  public void addPageMenuMoreChild(View paramView1, View paramView2)
  {
    this.fontSet = paramView1;
    this.wordSelectSet = paramView2;
  }

  public void addViewFilpper(ViewFlipper paramViewFlipper)
  {
    this.mViewFlipper = paramViewFlipper;
  }

  public void dismissMore()
  {
    dismiss();
    getViewFlipper().setVisibility(8);
    IKnow.mSystemConfig.saveBook_TextSize();
  }

  public ViewFlipper getViewFlipper()
  {
    return this.mViewFlipper;
  }

  public void initView(Window paramWindow, WindowManager.LayoutParams paramLayoutParams)
  {
    Button localButton1 = (Button)this.popView.findViewById(2131296496);
    Button localButton2 = (Button)this.popView.findViewById(2131296497);
    this.mSeekBar_font = ((SeekBar)this.fontSet.findViewById(2131296501));
    this.switch_bn_auto = ((ImageButton)this.wordSelectSet.findViewById(2131296507));
    this.font_progressShow = ((TextView)this.fontSet.findViewById(2131296500));
    this.switch_bn_auto.setBackgroundColor(0);
    IKnow.mSystemConfig.getBoolean("switch_bn_light");
    IKnow.mSystemConfig.getBoolean("switch_bn_word");
    if (IKnow.mSystemConfig.getBoolean("switch_bn_auto"))
      this.switch_bn_auto.setImageResource(2130837768);
    while (true)
    {
      getViewFlipper().setInAnimation(AnimationUtils.loadAnimation(this.ctx, 2130968581));
      getViewFlipper().setOutAnimation(AnimationUtils.loadAnimation(this.ctx, 2130968582));
      getViewFlipper().addView(this.fontSet);
      getViewFlipper().addView(this.wordSelectSet);
      localButton1.setOnClickListener(this.mBtnOnClickListener);
      localButton2.setOnClickListener(this.mBtnOnClickListener);
      this.switch_bn_auto.setOnClickListener(this.ChildImageButtonListener);
      this.mSeekBar_font.setOnSeekBarChangeListener(new SeekBarChangeListener(this));
      return;
      this.switch_bn_auto.setImageResource(2130837767);
    }
  }

  public class SeekBarChangeListener
  implements SeekBar.OnSeekBarChangeListener
  {
    protected WindowManager.LayoutParams attributes;
    public int interval = 3;
    protected Window window;

    public SeekBarChangeListener()
    {
      this.attributes = null;
      this.window = null;
      paramPageMenuMore.mSeekBar_font.setProgress((IKnow.mSystemConfig.getBook_TextSize() - 10) * this.interval);
    }

    public SeekBarChangeListener(, Window paramWindow, WindowManager.LayoutParams paramLayoutParams)
    {
      this.attributes = null;
      this.window = null;
      this.attributes = paramLayoutParams;
      this.window = paramWindow;
      float f = IKnow.mSystemConfig.getBook_Light();
      if (f == 0.0099999997764825821F)
        paramPageMenuMore.mSeekBar_light.setProgress(0);
      while (true)
      {
        return;
        paramPageMenuMore.mSeekBar_light.setProgress((int)(100.0F * f));
      }
    }

    public void onProgressChanged(, int paramInt, boolean paramBoolean)
    {
      switch (paramSeekBar.getId())
      {
      default:
      case 2131296501:
      case 2131296505:
      }
      while (true)
      {
        float f;
        do
        {
          while (true)
          {
            return;
            this.this$0.font_progressShow.setText(paramInt + "%");
            int i = 10 + Math.round(paramInt / this.interval);
            this.this$0.mSeekBar_font.setProgress(paramInt);
            IKnow.setTextSize(this.this$0.mAdapter, i);
          }
          this.this$0.light_progressShow.setText(paramInt + "%");
          f = (float)(paramInt / 100.0D);
          this.this$0.mSeekBar_light.setProgress(paramInt);
          this.attributes.screenBrightness = f;
        }
        while (f <= 0F);
        this.window.setAttributes(this.attributes);
      }
    }

    public void onStartTrackingTouch()
    {
      this.this$0.font_progressShow.setVisibility(0);
    }

    public void onStopTrackingTouch()
    {
      this.this$0.font_progressShow.setVisibility(4);
    }
  }
}